import request from '@/utils/request'

// 线圈派工查询页面
export function query(data) {
  return request({
    //baseURL:'',
    //url: `http://localhost:19004/stemDispatch/queryStemDispatchList`,
    url: `/md/stemDispatch/queryStemDispatchList`,
    method: `post`,
    data
  })
}

// 线圈派工查询页面导出
export function exportStemDispatch(data) {
  return request({
    url: `/md/stemDispatch/exportStemDispatch`,
    responseType: 'blob',
    method: `post`,
    data
  })
}

// 线圈工步派工查询页面导出
export function exportByDispatch(data) {
  return request({
    url: `/md/stemDispatch/exportByDispatch`,
    responseType: 'blob',
    method: `post`,
    data
  })
}

// 线圈工步派工查询页面
export function queryWorkStep(data) {
  return request({
    url: `/md/stemDispatch/needDispatchOrders`,
    method: `post`,
    data
  })
}

// 线圈工步改派查询页面
export function queryUpdateDispatch(data) {
  return request({
    url: `/md/stemDispatch/editDispatchList`,
    method: `post`,
    data
  })
}

// 分派根据设备类型查询
export function queryAssignment(data) {
  return request({
    url: `/md/stemDispatch/assignment`,
    method: 'post',
    data
  })
}

// 确认分派
export function confirmAssignment(data) {
  return request({
    url: `/md/stemDispatch/okAssignment`,
    // BaseUrl:'',
    // url: `http://localhost:19004/stemDispatch/okAssignment`,
    method: 'post',
    data
  })
}

// 确认改派
export function confirmUpdateDispatch(data) {
  return request({
    url: `/md/stemDispatch/okEditDispatch`,
    method: 'post',
    data
  })
}

// 线圈派工查询页面报工查询
export function queryBaoGon(data) {
  return request({
    //baseURL:'',
    //url: `http://localhost:19004/stemDispatch/selectStemReportWorkList`,
    url: `/md/stemDispatch/selectStemReportWorkList`,
    method: 'post',
    data
  })
}

// 线圈派工查询页面报工确认报工
export function confirmBaoGon(data) {
  return request({
    // baseURL:'',
    // url: `http://localhost:19004/stemDispatch/okStemReportWork`,
    url: `/md/stemDispatch/okStemReportWork`,
    method: 'post',
    data
  })
}

// 线圈不良登记 根据工单获取相关信息
export function queryByShopOrder(shopOrder) {
  return request({
    //baseURL:'',
    //url: `http://localhost:19004/stemDispatch/getItemInfoByShopOrder?shopOrderBo=${shopOrder}`,
    url: `/md/stemDispatch/getItemInfoByShopOrder?shopOrderBo=${shopOrder}`,
    method: 'get'
  })
}

export function queryBadRecords(data) {
  return request({
    //baseURL:'',
    //url: `http://localhost:19004/stemDispatch/getStepNcRecord`,
    url: `/md/stemDispatch/getStepNcRecord`,
    method: 'post',
    data
  })
}

// 导出
export function exportBadRecords(data) {
  return request({
    //baseURL:'',
    //url: `http://localhost:19004/stemDispatch/exportBadRecords`,
    url: `/md/stemDispatch/exportBadRecords`,
    responseType: 'blob',
    method: 'post',
    data
  })
}

export function saveNcRecord(data) {
  return request({
    //baseURL:'',
    //url: `http://localhost:19004/stemDispatch/stemNcRecord`,
    url: `/md/stemDispatch/stemNcRecord`,
    method: 'post',
    data
  })
}

// 查询所有可撤回的派工单
export function listAllCanCancelDispatchOrder(current, size, dispatchOrder, itemDesc) {
  return request({
    url: `/md/stemDispatch/listAllCanCancelDispatchOrder?current=${current}&size=${size}&dispatchOrder=${dispatchOrder}&itemDesc=${itemDesc}`,
    method: 'get'
  })
}

/**
 * 查询可撤回的下达派工单
 * @param data => dispatchOrders ['']
 */
export function dispatchOrders(data) {
  return request({
    url: `/md/stemDispatch/dispatchOrders`,
    method: 'post',
    data
  })
}

/**
 * 根据用户组ID查询所有人员信息
 * @param data
 * @returns {AxiosPromise}
 */
export function selectUserByRoleId(data) {
  return request({
    url: `/md/stemDispatch/selectUserByRoleId?roleId=${data}`,
    method: 'get',
    data
  })
}

// 线圈改派查询
export function editDispatchListNew(data) {
  return request({
    url: `/md/stemDispatch/editDispatchListNew?dispatchCode=${data}`,
    method: 'get',
    data
  })
}

// 确认改派-新
export function okAssignmentGaiPai(data) {
  return request({
    url: `/md/stemDispatch/okAssignmentGaiPai`,
    method: 'post',
    data
  })
}

// 线圈不良信息模糊查询
export function findNcCountsInfo(data) {
  return request({
    //baseURL:'',
    //url: `http://localhost:19004/stemDispatch/findNcCountsInfo`,
    url: `/md/stemDispatch/findNcCountsInfo`,
    method: 'post',
    data
  })
}

// 不良登记模糊查询
export function findNcRecords(data) {
  return request({
    url: `/md/stemDispatch/findNcRecords`,
    // url: `http://localhost:19004/stemDispatch/findNcRecords`,
    method: 'post',
    data
  })
}
